<?php

class Events extends AppModel {
	public $name="Event";
	public $belongsTo =array('Services'=> array(
            'className' => 'Services',
            'foreignKey' => 'service_id'
        ),'Clients'=>array(
            'className' => 'Clients',
            'foreignKey' => 'client_id'
        )
        ,'Branches'=>array(
            'className' => 'Branches',
            'foreignKey' => 'branch_id'
        )
        ); 

    public function beforeSave($options=array()){
        $date = date('Y-m-d', strtotime( $this->data['Events']['date']));
        $this->data['Events']['date']=$date;
        $time_from = date('H:i:s', strtotime( $this->data['Events']['time_from']));
        $this->data['Events']['time_from']=$time_from;
        $service = $this->Services->findById($this->data['Events']['service_id']); 

         
        //var_dump($this->data);
        //$time->add(new DateInterval('PT' . $time_to . 'M'));
        //var_dump($time);
        return true;
    }

}